package com.ruoyi.web.sso.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.sso.domain.GroupInfo;
import com.ruoyi.web.sso.service.IGroupInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 集团详情信息Controller
 * 
 * @author qiufeng
 * @date 2022-06-23
 */
@Controller
@RequestMapping("/sso/groupInfo")
public class GroupInfoController extends BaseController
{
    private String prefix = "sso/groupInfo";

    @Autowired
    private IGroupInfoService groupInfoService;

    @RequiresPermissions("sso:groupInfo:view")
    @GetMapping()
    public String groupInfo(String groupId, ModelMap mmap)
    {
        mmap.put("groupId", groupId);
        return prefix + "/groupInfo";
    }


    /**
     * 查询集团详情信息列表
     */
    @RequiresPermissions("sso:groupInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GroupInfo groupInfo)
    {
        startPage();
        List<GroupInfo> list = groupInfoService.selectGroupInfoList(groupInfo);
        return getDataTable(list);
    }

    /**
     * 导出集团详情信息列表
     */
    @RequiresPermissions("sso:groupInfo:export")
    @Log(title = "集团详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GroupInfo groupInfo)
    {
        List<GroupInfo> list = groupInfoService.selectGroupInfoList(groupInfo);
        ExcelUtil<GroupInfo> util = new ExcelUtil<GroupInfo>(GroupInfo.class);
        return util.exportExcel(list, "集团详情信息数据");
    }

    /**
     * 新增集团详情信息
     */
    @GetMapping("/add")
    public String add(String groupId, ModelMap mmap)
    {
        mmap.put("groupId", groupId);
        return prefix + "/add";
    }




    /**
     * 新增保存集团详情信息
     */
    @RequiresPermissions("sso:groupInfo:add")
    @Log(title = "集团详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GroupInfo groupInfo)
    {
        return toAjax(groupInfoService.insertGroupInfo(groupInfo));
    }

    /**
     * 修改集团详情信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        GroupInfo groupInfo = groupInfoService.selectGroupInfoById(id);
        mmap.put("groupInfo", groupInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存集团详情信息
     */
    @RequiresPermissions("sso:groupInfo:edit")
    @Log(title = "集团详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GroupInfo groupInfo)
    {
        return toAjax(groupInfoService.updateGroupInfo(groupInfo));
    }

    /**
     * 删除集团详情信息
     */
    @RequiresPermissions("sso:groupInfo:remove")
    @Log(title = "集团详情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(groupInfoService.deleteGroupInfoByIds(ids));
    }
}
